package engine.core
{
	import flash.display.*;
	import flash.display3D.*;
	import flash.external.*;
	import flash.system.*;
	import flash.utils.*;
	
	public class RxSystemInfo
	{
		public static const HW_ENABLED:uint = 0;
		public static const HW_DISABLED_UNKNOWN_CAUSE:uint = 1;
		public static const HW_DISABLED_USER_DISABLED:uint = 2;
		public static const HW_DISABLED_OLD_DRIVER:uint = 3;
		public static const HW_DISABLED_UNAVAILABLE:uint = 4;
		public static const HW_DISABLED_EXPLICIT:uint = 5;
		private static var _majorPlayerVersion:int;
		private static var _minorPlayerVersion:int;
		public static var s_info:Object = null;
		
		public function RxSystemInfo()
		{
		}
		
		public static function Write(param1:Stage) : String
		{
			var _loc_2:* = Collect(param1);
			var bytes:* = new ByteArray();
			var _loc_4:* = _loc_2.os64Bit ? ("64-bit") : ("32-bit");
			bytes.writeUTFBytes(_loc_2.os + " (" + _loc_4 + ")\n");
			bytes.writeUTFBytes("Screen resolution is " + _loc_2.screenResolutionX + " x " + _loc_2.screenResolutionY + "\n");
			bytes.writeUTFBytes("System language is " + _loc_2.language.toUpperCase() + "\n");
			bytes.writeUTFBytes("Flash Player " + _loc_2.playerVersion + " " + _loc_2.playerType + " (" + _loc_2.playerConfiguration + " player)\n");
			bytes.writeUTFBytes("Flash Player Sandbox is " + _loc_2.playerSandbox + "\n");
			bytes.writeUTFBytes("Graphics driver is " + _loc_2.graphicsDriver + "\n");
			bytes.writeUTFBytes("Browser is " + _loc_2.browserType + " " + _loc_2.browserVersion + "\n");
			bytes.writeUTFBytes("SWF build configuration is " + String(_loc_2.swfConfiguration).toUpperCase() + "\n");
			bytes.writeUTFBytes(RxUtilities.scvt(_loc_2.memoryUsed, 2) + " used of " + RxUtilities.scvt(_loc_2.memoryTotal, 2) + " allocated\n");
			bytes.writeUTFBytes("\n");
			return bytes.toString();
		}
		
		public static function Collect(param1:Stage) : Object
		{
			var _loc_5:Context3D = null;
			var _loc_6:String = null;
			var _loc_7:String = null;
			var _loc_8:String = null;
			var _loc_9:int = 0;
			var _loc_10:String = null;
			var _loc_11:Array = null;
			var _loc_12:String = null;
			var _loc_2:* = new Object();
			_loc_2.os = Capabilities.os;
			if (Capabilities.supports64BitProcesses)
			{
				_loc_2.os64Bit = true;
			}
			else
			{
				_loc_2.os64Bit = false;
			}
			_loc_2.screenResolutionX = Capabilities.screenResolutionX;
			_loc_2.screenResolutionY = Capabilities.screenResolutionY;
			_loc_2.language = Capabilities.language;
			_loc_2.playerType = Capabilities.playerType;
			var _loc_3:* = Capabilities.version.split(/ |,"" |,/);
			_loc_2.playerVersion = _loc_3[1] + "." + _loc_3[2] + "." + _loc_3[3] + "." + _loc_3[4];
			if (Capabilities.isDebugger)
			{
				_loc_2.playerConfiguration = "debug";
			}
			else
			{
				_loc_2.playerConfiguration = "release";
			}
			_loc_2.playerSandbox = Security.sandboxType;
			var _loc_4:* = param1.stage3Ds[0];
			if (param1.stage3Ds[0] != null)
			{
				_loc_5 = _loc_4.context3D;
				if (_loc_5 == null)
				{
					_loc_2.graphicsDriver = "n/a";
					_loc_2.graphicsHardwareAcceleration = false;
				}
				else
				{
					_loc_2.graphicsDriver = _loc_5.driverInfo;
					_loc_2.graphicsHardwareAcceleration = _loc_5.driverInfo.toLowerCase().search("software") == -1;
				}
			}
			if (ExternalInterface.available)
			{
				_loc_6 = ExternalInterface.call("window.navigator.userAgent.toString");
				if (_loc_6 != null)
				{
					_loc_7 = "Unknown";
					_loc_8 = "";
					_loc_9 = _loc_6.indexOf("MSIE");
					if (_loc_9 == -1)
					{
						_loc_9 = _loc_6.indexOf("Chrome");
					}
					if (_loc_9 == -1)
					{
						_loc_9 = _loc_6.indexOf("Firefox");
					}
					if (_loc_9 == -1)
					{
						_loc_9 = _loc_6.indexOf("Safari");
					}
					if (_loc_9 == -1)
					{
						_loc_9 = _loc_6.indexOf("Opera");
					}
					if (_loc_9 != -1)
					{
						_loc_10 = _loc_6.slice(_loc_9);
						_loc_11 = _loc_10.split(/ |\/|;"" |\/|;/);
						_loc_7 = _loc_11[0];
						_loc_8 = _loc_11[1];
					}
					if (_loc_7 == "MSIE")
					{
						_loc_12 = ExternalInterface.call("window.navigator.platform.toString");
						if (_loc_12 == "Win32")
						{
							_loc_7 = "Internet Explorer (32-bit)";
						}
						if (_loc_12 == "Win64")
						{
							_loc_7 = "Internet Explorer (64-bit)";
						}
					}
					_loc_2.browserType = _loc_7;
					_loc_2.browserVersion = _loc_8;
				}
			}
			else
			{
				_loc_2.browserType = "n/a";
				_loc_2.browserVersion = "";
			}
			_loc_2.swfConfiguration = "live";
			_loc_2.memoryUsed = System.totalMemory - int(System.freeMemory);
			_loc_2.memoryTotal = System.totalMemory;
			return _loc_2;
		}
		
		public static function get majorPlayerVersion() : int
		{
			return _majorPlayerVersion;
		}
		
		public static function get minorPlayerVersion() : int
		{
			return _minorPlayerVersion;
		}
		
		public static function get supportsFullScreenKeyboard() : Boolean
		{
			return _majorPlayerVersion >= 11 && _minorPlayerVersion >= 3;
		}
		
		public static function get supportsRightClick() : Boolean
		{
			return _majorPlayerVersion >= 11 && _minorPlayerVersion >= 2;
		}
	}
}